@extends('layouts.back_stage')
@section('style')
    @parent
    <link rel="stylesheet" href="{{env('CDN_DOMAIN_NAME')}}/css/dateSelect.css"/>
@endsection
@section('script')
    @parent
    <script src="{{env('CDN_DOMAIN_NAME')}}/js/dateSelect.js"></script>
@endsection
@section('content')
    <style>
        .form-control{font-size:12px;}
    </style>
    <div class="container">
        <span style="display:none;" class="info_sum">{{$logs_count}}</span>
        <div class="pull-left" style="width: 100%;margin-top: 20px">
            <form action="/system/log" role="form" style="display: inline-block;margin-right: 10px">
                <label>管理员名：</label>
                <select name="admin_name" class="admin_name address" id="admin_name"  style="width: 150px">
                    <option value="">显示全部</option>
                    @foreach ($admins as $value)
                        <option value="{{$value->admin_name}}">{{$value->admin_name}}</option>
                    @endforeach
                </select>
                <label>时间：</label><input id="date1" class="form-control start_time" style="width:120px;display: inline-block;background:#fff;" name="start_at" type="text" value="{{ $search['start_at'] }}" readonly placeholder="开始时间" />
                <input id="date2" class="form-control end_time"  name="end_at" style="width:120px;display: inline-block;background:#fff;" type="text" value="{{ $search['end_at'] }}" readonly placeholder="结束时间" />
                <label>模糊搜索：</label><input type="text"  placeholder="请输入模糊字" class="form-control font_dim" style="width:200px;display: inline-block;" value="{{ $search['msg'] }}" name="msg">
                <button type="submit" class="btn btn-info" id="sort_btn" style="margin-bottom: 5px;">搜索</button>
            </form>
        </div>
        <table class="table" style="margin-bottom:0;">
            <caption style="font-size: 30px">系统日志</caption>
            <thead>
            <tr>
                <th class="col-md-2">序号</th>
                <th class="col-md-2">管理员名</th>
                <th class="col-md-2">手机号</th>
                <th class="col-md-2">操作时间</th>
                <th class="col-md-4">具体操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach($logs as $key => $log)
                <tr>
                    <td> {{$log->id}}</td>
                    <td> {{ $log->admin_name }}</td>
                    <td> {{ $log->tel }}</td>
                    <td> {{ $log->created_at }}</td>
                    <td> {{ $log->operate }}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
        <div style="float: right;margin:20px 0;"><button class="btn btn-info" onclick="turnPage()" style="float:right;">跳转</button><input type="text" class="form-control turnPage" style="width:6rem;float: right;margin:0 5px;"></div>
        <div style="float: right">{{ $logs->appends(['start_at'=>$search['start_at'],'end_at'=>$search['end_at'],'msg'=>$search['msg'],'admin_name'=>$admin_name])->links() }}</div>
    </div>
    <script>
        /*日期插件初始化*/
        $("#date1").dateSelect();
        $("#date2").dateSelect();
        //跳转判断
        function turnPage() {
            var count=$(".info_sum").text();
            var maxBage=Math.ceil( Number(count)/15 );
            var getPageNum = $('.turnPage').val();
            if(getPageNum == ""){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text('请输入页码！');
                $(".oSuccess").show(0).delay(1000).hide(0);
            }else if(getPageNum == "0"){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text('请输入正确的页码！');
                $(".oSuccess").show(0).delay(1000).hide(0);
            }else if(getPageNum>maxBage){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text('请输入正确的页码！');
                $(".oSuccess").show(0).delay(1000).hide(0);
            }else if(!/^[0-9]*$/.test(getPageNum)){
                $(".faceImg").attr("src","/img/weep.png");
                $(".oHandle").text('请输入数字！');
                $(".oSuccess").show(0).delay(1000).hide(0);
            } else {
                if ($.getUrlParam('page') == null) {
                    if(window.location.href.indexOf('&') > 0){
                        window.location.href = window.location.href + "&page=" + parseInt(getPageNum);
                    }else{
                        window.location.href = window.location.href + "?page=" + parseInt(getPageNum);
                    }
                }else{
                    replaceParamVal('page', parseInt(getPageNum));
                }
            }
        }
    </script>
@endsection